package day05;

import java.util.Scanner;

/**
 * Created by Shinelon on 2016/9/17.
 */
public class ATM {

    private int balance = 2000;

    public static void main(String[] args) {
        ATM atm = new ATM();
        Scanner scan = new Scanner(System.in);
        while (true) {
            System.out.println("欢迎使用自助存取机！\n  1,查询余额 2,取款 3，存款 4，退出");
            int read = scan.nextInt();
            switch (read){
                case 1:
                    atm.getBalance();
                    break;
                case 2:
                    atm.getMoney(scan);
                    break;
                case 3:
                    atm.cunMoney(scan);
                    break;


            }
            if (read==4){
                System.out.println("欢迎再次使用!");
                break;
            }
        }
    }

    public void getBalance(){
        System.out.println("您的余额为：" +  balance);
    }

    public void getMoney(Scanner scan) {
        System.out.println("请输入您要取的金额：");
        int read = scan.nextInt();
        if (read>balance){
            System.out.println("银行卡余额不足！");
        }
        else {
            System.out.println("取现成功！");
            balance -= read;
        }
    }
    public void cunMoney(Scanner scan){
        System.out.println("请您输入要存的钞票：" );
        int read = scan.nextInt();
        if (read<0)
        {
        System.out.println("哪有存负数的？？？");
        }
        else {
            System.out.println("存款成功！");
            balance +=read;
        }
    }

}